Post

Replies

Boosts

Views

Activity

Reply to URL init from bookmark throws with file doesn't exist.
I got my entire codebase on GitHub, I get the files from the users @Environment(\.importFiles). file(multipleOfType: [.audio]) { result in switch result { case .success(let urls): openSong (urls: urls) break case .failure(let error): print(error) break case .none: print("No item was selected") } } GitHub - https://github.com/Human-Entertainment/Listen-in-Place/blob/0e6521ea0036236192552cab6c896d620f3fb9d6/Shared/ContentView.swift#L35-L46 Because of the weird issue I got from the bookmark thing, I've refactored it so I don't get the URL from the bookmark immediately after. But there's still issues reading the file it seems, which I'm debugging further. (This doesn't return Future<Song, SongError>{ $0(.failure(.coundtReadFile)) } weirdly enough func load(url: URL, bookmark: Data) throws -> Future<Song, SongError> { var loaded: (URL?, Error?) = (nil, nil) let coordinator = NSFileCoordinator() url.coordinatedRead(coordinator) { inputURL,inputError	in loaded = (inputURL, inputError) } guard let loadURL = loaded.0 else { return Future<Song, SongError>{ $0(.failure(.coundtReadFile)) } } return Future<Song, SongError> { promise in self.threadPool.start() let loaded = self.asyncLoad(url: loadURL, bookmark: bookmark) loaded.whenSuccess { song in promise(.success(song)) } loaded.whenFailure { error in print(error) promise(.failure(.coundtReadFile)) } } } GitHub - https://github.com/Human-Entertainment/Listen-in-Place/blob/0e6521ea0036236192552cab6c896d620f3fb9d6/Shared/SongReader/Song.swift#L57-L81 This function could also be important if you're curious how I get the bookmark. func add(url: URL) {     container.performBackgroundTask { [self] context in         do {             let newSong = Songs(context: context)             let bookmark = try url.bookmarkData()             newSong.bookmark = bookmark             fetchSong(url: url, bookmark: bookmark)         } catch {             print("An error occured: \(error)")         }         try? context.save()         } } GitHub - https://github.com/Human-Entertainment/Listen-in-Place/blob/0e6521ea0036236192552cab6c896d620f3fb9d6/Shared/SongReader/Player.swift#L25-L42 I see you use the document in the apps sandboxing, which I don't do, so I assume that I did something wrong in requesting access for files outside my apps sandboxing? Cheers, Bastian Inuk Christensen
Jul ’20